package com.takeeasy.platform.util;

import java.io.IOException;
import java.io.StringWriter;

import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JSONUtil {
	private static final Logger logger = LoggerFactory.getLogger(JSONUtil.class);
	public static synchronized String getJSONString(Object obj) {
		ObjectMapper objectMapper = new ObjectMapper();
		try {
			StringWriter stringWriter = new StringWriter();
			objectMapper.writer().writeValue(stringWriter, obj);
			String jsonString = stringWriter.toString();
			logger.debug(jsonString);
			return jsonString;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "";
	}
}
